<template>
	<view>
		<view v-for="(item,index) in order" :key="index" style="border-bottom: 1px solid #ddd;   margin-top: 10px;   display: flex;justify-content: space-between;align-items: center;">
			<view @click="orderto(index)" style="display: flex;flex-direction: column;justify-content: left; align-items: center;">
				<text>订单号:{{item.orderId}}</text>
				<text>金额:{{item.money}}元</text>
			</view>
			<view style="display: flex;flex-direction: column;align-items: center;">
				<text>{{item.time}}</text>
				<text>{{item.type}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{},
				order:{}
			}
		},
		methods: {
			orderto(index){
				uni.navigateTo({
					url: '/pages/order_details/order_details?orderId='+this.order[index].orderId+'&id='+this.order[index].id,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			getOrder(){
				uni.request({
					url: this.api.findByPayUser,
					method: 'POST',
					data: {
						userId:this.user.userId
					},
					success: res => {
						if(res.data.code==200){
							this.order=res.data.obj
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad() {
			if(uni.getStorageSync('token'))
			this.user=uni.getStorageSync('token')
			this.getOrder()
		}
	}
</script>

<style>

</style>
